﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Threading;
using System.Windows.Forms;

namespace PictureSplit
{
	// Token: 0x02000004 RID: 4
	public partial class PreviewForm : Form
	{
		// Token: 0x17000003 RID: 3
		// (set) Token: 0x0600000C RID: 12 RVA: 0x0000287B File Offset: 0x0000187B
		public string HtmlFileName
		{
			set
			{
				this.htmlFileName = value;
			}
		}

		// Token: 0x0600000D RID: 13 RVA: 0x00002885 File Offset: 0x00001885
		public PreviewForm()
		{
			this.InitializeComponent();
		}

		// Token: 0x0600000E RID: 14 RVA: 0x000028A0 File Offset: 0x000018A0
		private void writeOutPut(string output)
		{
			if (this.txtHtmlCode.InvokeRequired)
			{
				PreviewForm.WriteOutputDelegate method = new PreviewForm.WriteOutputDelegate(this.writeOutPut);
				base.Invoke(method, new object[]
				{
					output
				});
			}
			else
			{
				this.txtHtmlCode.AppendText(output);
			}
		}

		// Token: 0x0600000F RID: 15 RVA: 0x000028F4 File Offset: 0x000018F4
		private void LoadHtml()
		{
			try
			{
				StreamReader streamReader = new StreamReader(this.htmlFileName);
				string text;
				while ((text = streamReader.ReadLine()) != null)
				{
					text += "\r\n";
					this.writeOutPut(text);
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
			}
		}

		// Token: 0x06000010 RID: 16 RVA: 0x00002968 File Offset: 0x00001968
		private void PreviewForm_Load(object sender, EventArgs e)
		{
			this.Text = this.Text + "    " + this.htmlFileName;
			Thread thread = new Thread(new ThreadStart(this.LoadHtml));
			thread.Start();
			this.DisplaySplitGrid();
			this.webPreview.Visible = false;
			this.txtHtmlCode.Visible = true;
		}

		// Token: 0x06000011 RID: 17 RVA: 0x000029D0 File Offset: 0x000019D0
		private void tssPreview_Click(object sender, EventArgs e)
		{
			this.tssCode.Checked = false;
			this.tssPreview.Checked = true;
			this.webPreview.Visible = true;
			this.txtHtmlCode.Visible = false;
			this.tssDisplayGrid.Enabled = true;
		}

		// Token: 0x06000012 RID: 18 RVA: 0x00002A20 File Offset: 0x00001A20
		private void tssCode_Click(object sender, EventArgs e)
		{
			this.tssCode.Checked = true;
			this.tssPreview.Checked = false;
			this.webPreview.Visible = false;
			this.txtHtmlCode.Visible = true;
			this.tssDisplayGrid.Enabled = false;
		}

		// Token: 0x06000013 RID: 19 RVA: 0x00002A6F File Offset: 0x00001A6F
		private void tssExit_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		// Token: 0x06000014 RID: 20 RVA: 0x00002A7C File Offset: 0x00001A7C
		private void DisplaySplitGrid()
		{
			if (this.tssDisplayGrid.Checked)
			{
				this.webPreview.Url = new Uri(Application.StartupPath + "\\temp.htm");
			}
			else
			{
				this.webPreview.Url = new Uri(this.htmlFileName);
			}
		}

		// Token: 0x06000015 RID: 21 RVA: 0x00002ADC File Offset: 0x00001ADC
		private void tssDisplayGrid_Click(object sender, EventArgs e)
		{
			try
			{
				if (this.tssDisplayGrid.Checked)
				{
					this.tssDisplayGrid.Checked = false;
					this.DisplaySplitGrid();
				}
				else
				{
					this.tssDisplayGrid.Checked = true;
					this.DisplaySplitGrid();
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
			}
		}

		// Token: 0x0400000E RID: 14
		private string htmlFileName;

		// Token: 0x02000005 RID: 5
		// (Invoke) Token: 0x06000017 RID: 23
		private delegate void WriteOutputDelegate(string output);
	}
}
